<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="njtc" uri="http://www.njtcedu.cn/app/core"%>


<div class="setframe">
	<div class="setframeNav">
		<div class="left_nav">
			<h3 class="person_info">资料设置</h3>
			<li><div class="tagn">
					<a href="${pageContext.request.contextPath}/userinfo">个人资料</a>
				</div>
			</li>
			<li><div class="tago">
					<a href="${pageContext.request.contextPath}/userinfo/image">我的头像</a>
				</div>
			</li>
			<li>
				<div class="tagn">
					<a href="${pageContext.request.contextPath}/userinfo/passwd">修改密码</a>
				</div>
			</li>
			
			<li>
				<div class="tagn">
					<a href="${pageContext.request.contextPath}/user/index">个人首页</a>
				</div>
			</li>
		</div>
	</div>
	
	
	<div class="setframeWrap">
		<div class="set_warp" style="_width:750px;">
			<h3>修改我的头像</h3>
			<div style=" margin:0">
				<em class="s">用户头像会显示在<a href="index.php?mod=2" target="_blank">个人微博</a>页面，以及你的微博中！</em>
			</div>
			
			<span style="font-size:12px; color:#333; display:block; margin:10px 0;">选择头像图片</span>
			<img src="${pageContext.request.contextPath}/${currentUser.userImage}" id="current_user_image">
			<input type="file" name="imageFile" id="user_image_upload"/>
			<div>
				<div>
					<iframe id="uploadface" name="uploadface" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank">
						<img src="${pageContext.request.contextPath}/${currentUser.userImage}" id="current_image">
					</iframe>
				</div>
			</div>
			
			<form action="${pageContext.request.contextPath}" method="post" id="crop_form">
				 <input type="button" value="确认" id="crop_submit" class="btnText">
				 <input type="button" value="取消" class="canlText" onclick="updateavatar();">
			</form>
		</div>
	</div>
</div>

<script>
$('#crop_form').find('#crop_submit').click(function(){
	var rootPtah = "${pageContext.request.contextPath}";
    var url = "${pageContext.request.contextPath}/user/image/"; 
	$.ajaxFileUpload ({
		url : url,
		fileElementId :'user_image_upload',
		dataType : 'json',
		success : function (data, status){
			if (data) {
				$('#current_user_image').attr("src", rootPtah + data.imageUrl);
			}
		},
		
		error: function (data, status, e){
			alert(e);
			}
	});
});

</script>
